function r = mypolicyrule(r1,pi1,rho)

r = zeros(size(r1));

index1 = r1 <= 0 & pi1 < 2;

r(index1) = rho*r1(index1) ...
    + (1-rho)*(2 + 3*(pi1(index1) - 2));

r(~index1) = 0.8*r1(~index1) ...
    + (1-0.8)*(2 + 3*(pi1(~index1) - 2));

index2 = r < 0;
r(index2) = 0;

end